

<img src="" alt="暂无图片" id='MainGoodsGoodsDetail_Banner' style='width:100%;margin-top:30px' />

<div style='border-bottom:5px solid #fee;padding:10px 3px;'>商品标题：<span id='MainGoodsGoodsDetail_Title'>暂无</span></div>

<div style='border-bottom:5px solid #fee;padding:10px 3px;'>商品分类：<span id='MainGoodsGoodsDetail_Type'>暂无</span></div>

<div style='border-bottom:5px solid #fee;padding:10px 3px;'>商品价格：<span id='MainGoodsGoodsDetail_Price'>暂无</span></div>

<div style='border-bottom:5px solid #fee;padding:10px 3px;'>商品编号：<span id='MainGoodsGoodsDetail_Number'>暂无</span></div>

<div style='display:flex;padding:10px 3px;border-bottom:5px solid #fee'>
	
	<div style=''>商品详情：</div>

	<div style='flex:1;word-break:break-all' id='MainGoodsGoodsDetail_Info'>
		暂无
	</div>
</div>



<div style='padding:10px 3px;'>图片展示：</div>

<div style='margin-bottom:50px;' id='MainGoodsGoodsDetail_Imgs'>
	<!--img src="Public/Image/car1.jpg" style='width:100%' alt="暂无图片"-->
</div>


<div style='border-bottom:0px solid #fee;padding:10px 3px;'>
	商品状态：<span class='MainGoodsGoodsDetail_GoodsStat'></span>　
	<button onclick="MainGoodsGoodsDetail_ChangeGoodsStat(2)">通过</button>
	<button onclick="MainGoodsGoodsDetail_ChangeGoodsStat(3)">未通过</button>
	<button onclick="MainGoodsGoodsDetail_ChangeGoodsStat(4)">封禁</button>
	<button onclick="MainGoodsGoodsDetail_ChangeGoodsStat(1)">解封</button>
</div>

<div style='text-align:center;margin:20px auto'>
	<button onclick='MainGoodsGoodsDetail_Back()'>返回</button>
</div>



<script>
	var id = detail_id;		//当前商品id
	var info = '';
	MainGoodsDetail_GetDetail(); //获取商品详情

//获取商品详情数据
function MainGoodsDetail_GetDetail(){
	var data = {
		type:'GetGoodsDetail',
		id:id
	}
	Ajax2(data,function(res){
		C(res);
		MainGoodsDetail_GetDetail_Parse(res)
	},after_url);
}


	MainGoodsDetail_GetDetailImgs();	//获取商品详情的图片

//获取商品详情的图片列表并解析
function MainGoodsDetail_GetDetailImgs(){
	var data = {
		type:'GetGoodsDetailImgs',
		id:id
	}
	Ajax2(data,function(res){
		if(!/^\[{"addr":.*$/.test(res)){
			return;
		}
		var imgs = JSON.parse(res);
		var str = '';
		for(var i=0;i<imgs.length;i++){
			var a = upyun_shop_img+imgs[i].addr;
			C(a);
			str += "<img src='"+upyun_shop_img+imgs[i].addr+"' style='width:100%' /><br>";
		}
		$('#MainGoodsGoodsDetail_Imgs').html(str);
	},after_url);
}

//解析商品详情数据
function MainGoodsDetail_GetDetail_Parse(res){
	if(!/^{"id":.*$/.test(res)){
		return;
	}
	info = JSON.parse(res);
	if(info.banner){
		$('#MainGoodsGoodsDetail_Banner').attr('src',upyun_shop_img+info.banner);
	}
	$('#MainGoodsGoodsDetail_Title').text(ChangeChar(info.title,1));
	$('#MainGoodsGoodsDetail_Type').text(info.type_set);
	$('#MainGoodsGoodsDetail_Price').text(info.price+' 元');
	$('#MainGoodsGoodsDetail_Number').text(info.number);
	$('#MainGoodsGoodsDetail_Info').text(ChangeChar(info.info,1));

	//状态
	switch(info.goods_stat){
		case '1':var stat_str = '通过';var stat_str2 = '待审';break;
		case '2':case '5':var stat_str = '未通过';var stat_str2 = '<span style="color:blue">正常</span>';break;
		case '3':var stat_str = '封禁';var stat_str2 = '未通过';break;
		case '4':var stat_str = '解封';var stat_str2 = '已封禁';break;
	}

	$('.MainGoodsGoodsDetail_GoodsStat').html(stat_str2);
	$('.MainGoodsGoodsDetail_GoodsStatBtn').text(stat_str);
}

	//切换商品状态 
	function MainGoodsGoodsDetail_ChangeGoodsStat(stat){
		MainGoods_ChangeGoodsStat(id,stat);
		MainGoodsDetail_GetDetail(); //获取商品详情
		//MainGoodsGoodsDetail_Back();
	}


	//返回按钮
	function MainGoodsGoodsDetail_Back(){
		$('#MainGoods_GoodsDetail').hide();
		$('#MainGoods_GoodsListArea').show();
		MainGoods_GetGoodsList();
	}

</script>